import java.util.Random;
import java.util.Scanner;

public class Exec03 {

    public static void main(String[] args) {
        // 随机生成一个1-100之间的数据，提示用户猜测，猜大提示过大，猜小提示过小，直到猜中，结束游戏
        Random rand = new Random();
        // rand.nextInt(100)  [0, 99]
        int number = rand.nextInt(100) + 1; // 生成的随机数
        System.out.println("请输入你猜测的数字");
        Scanner sc = new Scanner(System.in);
        int guess = sc.nextInt();
        while (true) {
            if (guess > number) {
                System.out.println("过大");
                System.out.println("请重新输入：");
                guess = sc.nextInt();
            } else if (guess < number) {
                System.out.println("过小");
                System.out.println("请重新输入");
                guess = sc.nextInt();
            } else {
                System.out.println("恭喜，猜测成功！");
                break;
            }
        }
    }
}
